#!/usr/bin/python
# -*- coding: UTF-8 -*-

import pandas as pd
from wordcloud import WordCloud
import matplotlib.pyplot as plt


def wc():
    # 加载原始数据，查看前5条
    covid = 'clean.csv'
    png_name = 'word_cloud.png'
    df = pd.read_csv(covid, index_col=0)
    all_words = ' '.join(df['text'].values)
    wordcloud = WordCloud(width=800, height=500, random_state=21, max_font_size=110,collocations=False)\
        .generate(all_words)
    wordcloud.to_file(png_name)
    # 画图
    # plt.figure(figsize=(10, 7))
    # plt.imshow(wordcloud, interpolation="bilinear")
    # plt.axis('off')
    # plt.savefig('word_cloud.png')


if __name__ == '__main__':
    wc()
